/**
 * 显示列表以及查询数据源
 */
import React, { Component } from 'react'
// 引入表内容
import ProductTypeTable from './ProductTypeTable'

//引入级联操作
import Casca from './Cascader'
//引入日期
import ProductDate from './ProductDate'
//引入列表
import ProductTypeTableTree from './ProductTypeTableTree'
// 引入评价

import $http from '../../Utils/request'
import storage from '../../Utils/storage'

//创建请求头文件
let config = {}
if(storage.get("token") !== null){
  config = {
    headers:
      {'Content-Type': 'application/json',
        'token':storage.get("token").data
      }
  }
}else{
  config = {
    headers:
      {'Content-Type': 'application/json'
      }
  }
}

export default class Table extends Component {
  //创建变量
  state = {
    productTypeArray : [] // 用于展示数据用
  }
  //创建初始化钩子函数
  componentDidMount () {
    $http.get("http://localhost/mall-basic-service/basic/productType/queryBasicProductTypeAll",config).then((response)=>{
      //定义接收数组
      let data = [];
      if(response.data.code === 0){
        data.push(response.data.data[0])
      }
      //数据重组
      this.setState({
        productTypeArray: data
      })
    })
  }

  render () {
    return (
      <div className="bodyDiv" style={{width:1150}}>
        {/*以列表的形式展示*/}
        <ProductTypeTableTree dataSource={this.state.productTypeArray}/>
        {/**/}
        <ProductTypeTable dataSource={this.state.productTypeArray}/>
        <Casca dataSource={this.state.productTypeArray}/>
        <ProductDate/>
      </div>
    )
  }
}
